{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
</head>
<body>
<div>
      <form   action="{% url 'spi:register' %}" method="post" >
        {% csrf_token %}
          <p id="txt"></p>
        <input type="text"  name="username" id="username" placeholder="用户名"><br>
        <input type="text"  name="phone" id="phone" placeholder="phone"><br>
        <input type="text"  name="mail" id="mail" placeholder="mail"><br>
        <input type="password"  name="password" id="password" placeholder="密码"><br>
        <button type="submit" value="登陆">注册</button>
    </form>
{#    <button id="but">点击</button>#}

</div>
</body>
<script src="{%  static 'js/jquery.js'%}"></script>
<script>
    $(function () {
        $('#phone').blur(function () {
            let phone = $(this).val();
            $.ajax({
                url:'/spi/chk_phone?phone='+phone,
                type:'GET',
                success:function (data) {
                    a =data.login_case;
                    if (a == 'ok')  {
                        $('#txt').text('改电话已存在');
                        $(this).val('');
                        {#return false#}
                    }else {
                        $('#txt').text('')
                    }
                }
            })
        })
    })
</script>
</html>